package com.example.wheelguide;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class RouteActivity extends Activity{
	Button button1;
    RadioButton rb;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		button1= new Button(this);
		setContentView(R.layout.route);
		
		button1= (Button) findViewById(R.id.button_back);
		
		button1.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
				
			}
		});
		
		button1= (Button) findViewById(R.id.Button_Route_Calculate);
		
		button1.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				EditText et= new EditText(v.getContext());
				AlertDialog alertDialog = new AlertDialog.Builder(v.getContext()).create();
				boolean getAlert=false;
				String text="";
				
				et = (EditText) findViewById(R.id.EditText_from_street);
				if(et.getText().length()==0)
				{
					et.setBackgroundColor(TRIM_MEMORY_BACKGROUND);
					getAlert=true;
					text=text+"Start Strasse, ";
				}
				et = (EditText) findViewById(R.id.EditText_from_street_number);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Start Strassennummer, ";
				}
				et = (EditText) findViewById(R.id.EditText_from_place);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Start Ort, ";
				}
				et= (EditText) findViewById(R.id.EditText_from_zipcode);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Start PLZ, ";
				}
				
				et = (EditText) findViewById(R.id.EditText_to_Street);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Ziel Strasse, ";
				}
				et = (EditText) findViewById(R.id.EditText_to_Street_number);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Ziel Strassennummer, ";
				}
				et = (EditText) findViewById(R.id.EditText_To_Place);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Ziel Ort, ";
				}
				et = (EditText) findViewById(R.id.EditText_To_Zipcode);
				if(et.getText().length()==0)
				{
					getAlert=true;
					text=text+"Ziel PLZ, ";
				}
				
				if(getAlert)
				{
					alertDialog.setTitle("!!!Angaben fehlen!!!");
					alertDialog.setMessage(text+" fehlt");
					alertDialog.setButton(1,"OK", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.cancel(); 
					}
					});
					alertDialog.show();
				}
			}
		});
		
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
